define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function ()
        {
            $(document).on('click','.ze',function (){
                var that = $(this);
                var url = that.data('url');
                var herf = that.data('herf');
                Layer.confirm('确认开始吗', {
                    btn: ['确认','取消'] //按钮
                }, function(){
                    layer.load(1)
                    $.ajax({
                        url:url,
                        type:'post',
                        dataType: 'json',
                        success:function (data) {
                            if(data.code == 1){
                                Layer.msg('操作成功,3秒之后将进入同步记录');
                                layer.closeAll('loading');

                                setTimeout(function(){
                                    window.open(herf,'_blank');
                                },3000);
                            }else{
                                Layer.alert(data.msg);
                                layer.closeAll('loading');
                            }
                        },
                    })
                    return true;
                }, function(){
                    return false;
                });
            });
            $(document).on('click', '.action_datacenter', function ()
            {
                var that = $(this)
                var id   = that.data('id')
                var title   = that.data('title') + '数据同步'
                Fast.api.open("/BdlLogin.php/Synchronous/action?id="+id, title, {
                    callback:function(value)
                    {
                        console.log(value)
                        return false;
                    }
                });
            });
            $(document).on('click', '.copy_datacenter', function ()
            {
                var that = $(this)
                var id   = that.data('id')
                var title   = that.data('title')+ '数据拷贝'



                Fast.api.open("/BdlLogin.php/Synchronous/copy?id="+id, title, {
                    callback:function(value)
                    {
                        console.log(value)
                        return false;
                    }
                });
            });

            Form.api.bindevent("form[role=form]", function(data, ret){
                return false;
            });

        },
        action: function ()
        {

            Form.api.bindevent("form[role=form]", function(data, ret){
                return false;
            });

            Controller.api.bindevent();
        },
        copy: function ()
        {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }

        }
    };

    return Controller;
});
